﻿using System;
using System.Windows;
using $RootNamespace$.Infrastructure;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Composite.Regions;
using Microsoft.Practices.Unity;

namespace $ModuleNamespace$
{
    [Module(ModuleName = "$ModuleName$")]
    public class $ModuleName$ : IModule
    {
        private readonly IUnityContainer unityContainer;
        private readonly IRegionManager regionManager;

        /// <summary>
        /// Initializes a new instance of the <see cref="$ModuleName$"/> class.
        /// </summary>
        /// <param name="unityContainer">The unity container.</param>
        /// <param name="regionManager">The region manager.</param>
        public $ModuleName$(IUnityContainer unityContainer, IRegionManager regionManager)
        {
            this.unityContainer = unityContainer;
            this.regionManager = regionManager;
        }

        /// <summary>
        /// Initializes the module. This method is called by the Prism infrastructure.
        /// </summary>
        /// <remarks>
        /// Here you can add the logic needed to setup the module when it is loaded for the first time.
        /// </remarks>
        public void Initialize()
        {
            MergeResourceDictionary();
        }

        private void MergeResourceDictionary()
        {
            var dictionary = new ResourceDictionary {Source = new Uri("pack://application:,,,/$ModuleNamespace$;Component/ModuleResourceDictionary.xaml")};
            Application.Current.Resources.MergedDictionaries.Add(dictionary);
        }
    }
}